/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JDialogArticulo.java
 *
 * Created on Jun 5, 2010, 10:24:11 AM
 */

package tiendagui.internal;


import controller.ControllerArticulo;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JPanel;

import entities.vo.ArticuloVO;

/**
 *
 * @author Jhonny
 */
public class JDialogArticulo extends javax.swing.JDialog {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private ControllerArticulo controller;
    /** Creates new form JDialogArticulo */
    public JDialogArticulo(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        controller = new ControllerArticulo(this);
        initComponents();

    }
    public void setArticulo(ArticuloVO articulo){
        controller.setArticulo(articulo);
    }

    @Override
    public void setVisible(boolean b) {
        if(b){
            try {
                controller.initComponentView();
            } catch (FileNotFoundException ex) {
                Logger.getLogger(JDialogArticulo.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(JDialogArticulo.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        super.setVisible(b);
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        labelReferencia = new javax.swing.JLabel();
        labelStock = new javax.swing.JLabel();
        labelLinea = new javax.swing.JLabel();
        labelColor = new javax.swing.JLabel();
        labelSeccion = new javax.swing.JLabel();
        labelPrecio = new javax.swing.JLabel();
        labelOferta = new javax.swing.JLabel();
        textFieldReferencia = new javax.swing.JTextField();
        textFieldStock = new javax.swing.JTextField();
        textFieldLinea = new javax.swing.JTextField();
        textFieldColor = new javax.swing.JTextField();
        textFieldSeccion = new javax.swing.JTextField();
        textFieldPrecio = new javax.swing.JTextField();
        textFieldOferta = new javax.swing.JTextField();
        panelTipo = new javax.swing.JPanel();
        labelDescripcion = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jEditorPane1 = new javax.swing.JEditorPane();
        buttonCerrar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N
        setResizable(false);

        jPanel1.setName("jPanel1"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(tiendagui.TiendaGUIApp.class).getContext().getResourceMap(JDialogArticulo.class);
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), resourceMap.getString("jPanel2.border.title"))); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N

        labelReferencia.setText(resourceMap.getString("labelReferencia.text")); // NOI18N
        labelReferencia.setName("labelReferencia"); // NOI18N

        labelStock.setText(resourceMap.getString("labelStock.text")); // NOI18N
        labelStock.setName("labelStock"); // NOI18N

        labelLinea.setText(resourceMap.getString("labelLinea.text")); // NOI18N
        labelLinea.setName("labelLinea"); // NOI18N

        labelColor.setText(resourceMap.getString("labelColor.text")); // NOI18N
        labelColor.setName("labelColor"); // NOI18N

        labelSeccion.setText(resourceMap.getString("labelSeccion.text")); // NOI18N
        labelSeccion.setName("labelSeccion"); // NOI18N

        labelPrecio.setText(resourceMap.getString("labelPrecio.text")); // NOI18N
        labelPrecio.setName("labelPrecio"); // NOI18N

        labelOferta.setText(resourceMap.getString("labelOferta.text")); // NOI18N
        labelOferta.setName("labelOferta"); // NOI18N

        textFieldReferencia.setText(resourceMap.getString("textFieldReferencia.text")); // NOI18N
        textFieldReferencia.setName("textFieldReferencia"); // NOI18N

        textFieldStock.setName("textFieldStock"); // NOI18N

        textFieldLinea.setText(resourceMap.getString("textFieldLinea.text")); // NOI18N
        textFieldLinea.setName("textFieldLinea"); // NOI18N

        textFieldColor.setText(resourceMap.getString("textFieldColor.text")); // NOI18N
        textFieldColor.setName("textFieldColor"); // NOI18N

        textFieldSeccion.setText(resourceMap.getString("textFieldSeccion.text")); // NOI18N
        textFieldSeccion.setName("textFieldSeccion"); // NOI18N

        textFieldPrecio.setText(resourceMap.getString("textFieldPrecio.text")); // NOI18N
        textFieldPrecio.setName("textFieldPrecio"); // NOI18N

        textFieldOferta.setText(resourceMap.getString("textFieldOferta.text")); // NOI18N
        textFieldOferta.setName("textFieldOferta"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(labelReferencia)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldReferencia, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(labelStock)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldStock))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(labelLinea)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldLinea))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(labelColor)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldColor))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(labelSeccion)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldSeccion))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(labelPrecio)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldPrecio))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(labelOferta)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFieldOferta)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelReferencia)
                    .addComponent(textFieldReferencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelStock)
                    .addComponent(textFieldStock, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelLinea)
                    .addComponent(textFieldLinea, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelColor)
                    .addComponent(textFieldColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelSeccion)
                    .addComponent(textFieldSeccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelPrecio)
                    .addComponent(textFieldPrecio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelOferta)
                    .addComponent(textFieldOferta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(12, Short.MAX_VALUE))
        );

        panelTipo.setName("panelTipo"); // NOI18N

        javax.swing.GroupLayout panelTipoLayout = new javax.swing.GroupLayout(panelTipo);
        panelTipo.setLayout(panelTipoLayout);
        panelTipoLayout.setHorizontalGroup(
            panelTipoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 256, Short.MAX_VALUE)
        );
        panelTipoLayout.setVerticalGroup(
            panelTipoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 49, Short.MAX_VALUE)
        );

        labelDescripcion.setText(resourceMap.getString("labelDescripcion.text")); // NOI18N
        labelDescripcion.setName("labelDescripcion"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jEditorPane1.setName("jEditorPane1"); // NOI18N
        jScrollPane1.setViewportView(jEditorPane1);

        buttonCerrar.setText(resourceMap.getString("buttonCerrar.text")); // NOI18N
        buttonCerrar.setName("buttonCerrar"); // NOI18N
        buttonCerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonCerrarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(panelTipo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelDescripcion)
                .addContainerGap(185, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(183, Short.MAX_VALUE)
                .addComponent(buttonCerrar)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(labelDescripcion)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonCerrar)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-272)/2, (screenSize.height-428)/2, 272, 428);
    }// </editor-fold>

    private void buttonCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCerrarActionPerformed
        controller.cerrar();
    }//GEN-LAST:event_buttonCerrarActionPerformed

    public JPanel getPanelTipo() {
        return panelTipo;
    }


    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                JDialogArticulo dialog = new JDialogArticulo(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonCerrar;
    private javax.swing.JEditorPane jEditorPane1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel labelColor;
    private javax.swing.JLabel labelDescripcion;
    private javax.swing.JLabel labelLinea;
    private javax.swing.JLabel labelOferta;
    private javax.swing.JLabel labelPrecio;
    private javax.swing.JLabel labelReferencia;
    private javax.swing.JLabel labelSeccion;
    private javax.swing.JLabel labelStock;
    private javax.swing.JPanel panelTipo;
    private javax.swing.JTextField textFieldColor;
    private javax.swing.JTextField textFieldLinea;
    private javax.swing.JTextField textFieldOferta;
    private javax.swing.JTextField textFieldPrecio;
    private javax.swing.JTextField textFieldReferencia;
    private javax.swing.JTextField textFieldSeccion;
    private javax.swing.JTextField textFieldStock;
    // End of variables declaration//GEN-END:variables
	public void setReferencia(Integer referencia) {
		textFieldReferencia.setText(referencia+"");
		
	}
	public void setLinea(String linea) {
		textFieldLinea.setText(linea);		
	}
	public void setDescripcion(String descripcion) {
		jEditorPane1.setText(descripcion);		
	}
	public void setColor(String color) {
		textFieldColor.setText(color);		
	}
	public void setSeccion(String seccion) {
		textFieldSeccion.setText(seccion);		
	}
	public void setPrecioUnitario(Float precioUnitario) {		
		textFieldPrecio.setText(precioUnitario+"");
	}
	public void setPrecioOferta(Float precioOferta) {
		textFieldOferta.setText(precioOferta+"");
	}
	public void setStock(Integer stock) {
		textFieldStock.setText(stock+"");		
	}

}
